package com.erp.controller;


import com.erp.mapper.LogMapper;
import com.erp.tool.PgTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class LogController {

    @Autowired
    private LogMapper mapper;

    //分页查
    @RequestMapping("/limitLogs")
    public List limitUsers(String date, int num){
        System.out.println(date);
        List<Object>allList = new ArrayList<Object>();
        int row=4;
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("date",date);
        map.put("end",row);
        map.put("start", PgTool.getStart(num,row).get("start"));
        //查询需多少页
        allList.add(PgTool.getPage(row, mapper.countLogos(map)));
        //得到分页数据
        allList.add(mapper.findAllLogs(map));
        return allList;
    }


}
